<template>
	<view>
		<view>
			<view class="model">
				图片上传
			</view>
			<button @click="changeFile">点击上传文件（点击图片预览）</button>
			<image @click="doPriview" width="150" height="150" v-for="item in imgUrls" :key="item" :src="item"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrls:[]
			}
		},
		onLoad() {
			uni.setStorageSync('kye', 'value')
			console.log(uni.getStorageInfoSync())
		},
		methods: {
			//预览
			doPriview() {
				uni.previewImage({
					urls: this.imgUrls//临时路径可以预览，可以预览多个
				})
			},
			//点击上传图片
			changeFile() {
				uni.chooseImage({
					count: 3,
					type: 'image',
					extension:['.png'],
					success: (res) => {
						this.imgUrls = res.tempFilePaths
						// uni.saveFile({
						// 	tempFilePath: res.tempFilePaths[0],
						// 	success: (result) => {
						// 		console.log(result)
						// 		uni.getSavedFileList({
						// 			success: (fileList) => {
						// 				console.log(fileList)
						// 			}
						// 		})
						// 	}
						// })
					}
				})
			}
		}
	}
</script>

<style>
	.model{
		margin-bottom: 30rpx;
	}
</style>